# -*- coding: utf-8 -*-
"""
@Time   : 2019/11/21 16:47
@Author : LeeCQ
"""
import requests
import random
import datetime
import threading
import time
import asyncio


async def asy1(name: str = "0"):
    print("{} begin".format(name))
    r = await asyncio.sleep(random.randint(1, 3))
    print("{} end".format(name))
    return "{} finish".format(name)


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    tasks = [asyncio.ensure_future(asy1(str(i))) for i in range(10)]
    loop.run_until_complete(asyncio.wait(tasks))
    print("all task is finish")
    loop.close()
